#include <stdio.h>  
#include <stdlib.h>  
#include <fcntl.h>  
#include <unistd.h>  
#include <sys/ioctl.h>
#include <string.h>

#include "misc_ioctl.h"

int main(void)
{
    int fd = -1;
    const char *str = "hello, form ioctl";
    ioctl_data_t data = {0};

    data.cmd = MISC_CMD_START;
    data.data_len = strlen(str) + 1;
    strcpy(data.data, str);

    fd = open(MISC_DEV_PATH, O_RDWR | O_NONBLOCK);
    if (fd == -1) {
        perror("open");  
        exit(EXIT_FAILURE);  
    }

    if (ioctl(fd, MISC_IOCTL_CMD, &data) == -1) {
        perror("ioctl");
        close(fd);
        exit(EXIT_FAILURE);
    }
    printf("%u %u %s\n", data.cmd, data.status, data.data);
    close(fd);
    return RET_SUCCESS;
}
